package com.lanou.utp.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lanou.utp.entity.Approval;
import com.lanou.utp.entity.Paging;
import com.lanou.utp.entity.ResponseData;
import com.lanou.utp.mapper.ApprovalMapper;
import com.lanou.utp.service.ApprovalService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author MaQingYun
 */
@Service
public class ApprovalServiceImpl implements ApprovalService {

    @Resource
    private ApprovalMapper approvalMapper;

    @Override
    public ResponseData getLeaveApprovalList(Long majorId, Integer page) {
        System.out.println("majorId = [" + majorId + "], page = [" + page + "]");
        Page<Object> objects = PageHelper.offsetPage((page - 1) * Paging.size, Paging.size);
        List<Approval> leaveApprovalList = this.approvalMapper.getLeaveApprovalList(majorId);
        return new ResponseData(leaveApprovalList, new Paging(page, objects.getTotal()));
    }


}
